﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    
    
    <ControlTemplate x:Key="TopMenu_TopLevelItem" TargetType="{x:Type MenuItem}">        
        <Border x:Name="border" Margin="3,0,3,0" Cursor="Hand" VerticalAlignment="Center">
            <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center">
                <ContentPresenter.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="Foreground" Value="{StaticResource TopMenuBrush}"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="TextDecorations" Value="Underline"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ContentPresenter.Resources>
            </ContentPresenter>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="TopMenu_SubmenuItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Margin="1" Cursor="Hand" CornerRadius="4" HorizontalAlignment="Stretch">
            <Grid Margin="2,2,20,2" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <ContentPresenter Grid.Column="0" ContentSource="Icon" Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <ContentPresenter Grid.Column="1"
                                  TextElement.FontSize="{StaticResource NormalFontSize}"
                                  ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                    
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="border" Property="Background" Value="{StaticResource TopMenuSelectedItemBackground}"/>
                <Setter TargetName="border" Property="TextBlock.Foreground" Value="{StaticResource TopMenuSelectedItemBrush}"/>                    
            </Trigger>
            <Trigger Property="IsMouseOver" Value="False">
                <Setter TargetName="border" Property="Background" Value="White"/>                
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="TopMenu_TopLevelHeader" TargetType="MenuItem">
        <Grid x:Name="grid" >

            <Border x:Name="border" Margin="3,0,3,0" Cursor="Hand" VerticalAlignment="Center" >
                <ContentPresenter ContentSource="Header" RecognizesAccessKey="True">
                    <ContentPresenter.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="{StaticResource TopMenuBrush}"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="TextDecorations" Value="Underline"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ContentPresenter.Resources>
                </ContentPresenter>
            </Border>
            <Popup 
                                    Name="Popup"
                                    Placement="Bottom"                                    
                                    StaysOpen="True"               
                                    IsOpen="{TemplateBinding IsSubmenuOpen}"
                                    AllowsTransparency="True" 
                                    Focusable="False"
                                    PopupAnimation="Fade">
                <Border
                                        Margin="0,0,5,5"
                                        CornerRadius="5,5,5,5"
                                        Name="SubmenuBorder"                              
                                        Background="{StaticResource ToolBarMenuDropDownBackground}"
                                        BorderBrush="{StaticResource ToolBarMenuBorderBrush}"
                                        BorderThickness="2">
                    <StackPanel                                            
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" />
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="2" Opacity="0.5" />
                    </Border.Effect>
                </Border>
            </Popup>
        </Grid>

        <ControlTemplate.Triggers>            
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>

            
        </ControlTemplate.Triggers>

    </ControlTemplate>

    

    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="MenuItem">
                    <Setter Property="Template" Value="{StaticResource TopMenu_SubmenuItem}"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource TopMenu_TopLevelHeader}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource TopMenu_TopLevelItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource TopMenu_SubmenuItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource TopMenu_TopLevelItem}"/>
            </Trigger>
        </Style.Triggers>

    </Style>

    <Style x:Key="SimpleSeparator" TargetType="Separator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Separator">
                    <TextBlock Text="|" Foreground="{StaticResource TopMenuBrush}" Margin="3,0,3,0" VerticalAlignment="Center"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    <Style TargetType="{x:Type Menu}">        
        <Setter Property="Padding" Value="0,0,0,0"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Margin" Value="5,0,0,0"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource TopMenuItemBrush}"/>            
    </Style>

    <!-- TOOLBARS MENUS -->
    <ControlTemplate x:Key="ToolBarMenu_TopLevelItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Style="{StaticResource MouseOverBorder}" MinWidth="60" MaxWidth="75" >
            <Grid Cursor="Hand" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="38"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ContentPresenter Grid.Row="0" ContentSource="Icon" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <Border x:Name="bg" CornerRadius="0,0,5,5" Grid.Row="1" Padding="1" VerticalAlignment="Stretch">                
                    <ContentPresenter  ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Top">
                        <ContentPresenter.Resources>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="TextAlignment" Value="Center"/>
                                <Setter Property="TextWrapping" Value="Wrap"/>
                                <Setter Property="FontSize" Value="{StaticResource SmallFontSize}"/>
                                <Setter Property="Foreground" Value="{StaticResource ToolBarItemBrush}"/>
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                    
                </Border>                
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="bg" Property="Background">
                    <Setter.Value>
                        <SolidColorBrush  Color="LightGray" Opacity="0.4"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter TargetName="border" Property="Background" Value="{StaticResource AlertBackgroundBrush}"/>
                <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AlertBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ToolBarMenu_SubmenuItem" TargetType="{x:Type MenuItem}">
        <Border x:Name="border" Style="{StaticResource MouseOverBorder}" Margin="1" Cursor="Hand">
            <Grid Margin="2,2,20,2" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <ContentPresenter Grid.Column="0" ContentSource="Icon" Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" />                
                <ContentPresenter Grid.Column="1" 
                                  TextElement.FontSize="{StaticResource NormalFontSize}"
                                  ContentSource="Header" 
                                  RecognizesAccessKey="True" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ContentPresenter.Resources>
                    </ContentPresenter.Resources>
                </ContentPresenter>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ToolBarMenu_TopLevelHeader" TargetType="MenuItem">
        <Grid x:Name="grid">

            <Border x:Name="border" Style="{StaticResource MouseOverBorder}" MinWidth="60" MaxWidth="70" >
                <Grid Cursor="Hand" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="38"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ContentPresenter Grid.Row="0" ContentSource="Icon" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    <Border x:Name="bg" CornerRadius="0,0,5,5" Grid.Row="1" Padding="1" VerticalAlignment="Stretch" >
                        <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Top">
                        <ContentPresenter.Resources>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="TextAlignment" Value="Center"/>
                                <Setter Property="TextWrapping" Value="Wrap"/>
                                <Setter Property="FontSize" Value="{StaticResource SmallFontSize}"/>
                                <Setter Property="Foreground" Value="{StaticResource ToolBarItemBrush}"/>
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                    </Border>
                </Grid>
            </Border>
            <Popup 
                                    Name="Popup"
                                    Placement="Bottom"                                    
                                    StaysOpen="True"               
                                    IsOpen="{TemplateBinding IsSubmenuOpen}"
                                    AllowsTransparency="True" 
                                    Focusable="False"
                                    PopupAnimation="Fade">
                <Border
                                        Margin="0,0,5,5"
                                        CornerRadius="5,5,5,5"
                                        Name="SubmenuBorder"                              
                                        Background="{StaticResource ToolBarMenuDropDownBackground}"
                                        BorderBrush="{StaticResource ToolBarMenuBorderBrush}"
                                        BorderThickness="2">
                    <StackPanel                                            
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" />
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="2" Opacity="0.5" />
                    </Border.Effect>
                </Border>
            </Popup>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="bg" Property="Background">
                    <Setter.Value>
                        <SolidColorBrush  Color="LightGray" Opacity="0.4"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="border" Property="Opacity" Value="0.5"/>
            </Trigger>

            <Trigger Property="IsChecked" Value="True">
                <!--<Setter TargetName="label" Property="Border.Background" Value="{StaticResource AlertBackgroundBrush}"/>
                                    <Setter TargetName="label" Property="Border.BorderBrush" Value="{StaticResource AlertBrush}"/>
                                    <Setter TargetName="PrimaryContent" Property="TextBlock.Foreground" Value="{StaticResource AlertBrush}"/>-->
            </Trigger>

        </ControlTemplate.Triggers>

    </ControlTemplate>

    <Style x:Key="Toolbar_MenuItemStyle" TargetType="MenuItem">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="MenuItem">
                    <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubmenuItem}"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelHeader}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubmenuItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelItem}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="Toolbar_MenuItemStyleHideWhenDisabled" TargetType="MenuItem" BasedOn="{StaticResource Toolbar_MenuItemStyle}">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="GoBackMenuItem" TargetType="{x:Type MenuItem}" BasedOn="{StaticResource Toolbar_MenuItemStyle}" x:Shared="false">
        <Setter Property="Header" Value="{x:Static props:Resources.Back}"/>
        <Setter Property="Command" Value="{Binding CloseWindowCommand}"/>
        <Setter Property="Icon">
            <Setter.Value>
                <Image Source="/Images/ToolBar/Back.png" Width="32" Height="32" Stretch="Uniform" />
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>